<template>
	<div>
		<el-row :gutter="20">
			<el-col span="4">
				<el-input placeholder="请输入要充值的账户" v-model="phone"></el-input>
			</el-col>
			<el-col span="4">
				<el-input placeholder="请输入要充值的金额" v-model="money"></el-input>
			</el-col>
			<el-col span="4">
				<el-button @click="recharge">确定</el-button>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	import{getuserlist} from "../api.js"
	import{recharge} from "../api.js"
	export default{
		data() {
			return {
				phone: "",
				money: "",
				userid: "",
			}
		},
		methods: {
			recharge() {
				if(this.phone=="" || this.money=="") {
					this.$message({
						type:'error',
						message:"充值的账户或金额不能为空",
					})
				}
				else {
					this.$confirm('确定要充值吗？','提示',{
						confirmButtonText:'确定',
						cancelButtonText:'取消',
						type:'warning',
					}).then(()=>{
						var params={
							phone:this.phone,
						}
						getuserlist(params).then(res=>{
							let result=res.data
							console.log(result)
							if(result.status !==0) {
								this.$message({
									message:result.msg,
									type:'error'
								});
							}
							else {
								this.userid=result.data[0].id
								console.log(this.userid)
								var rechargeparams={
									userId:this.userid,
									money:this.money
								}
								recharge(rechargeparams).then(res=>{
									let result = res.data
									console.log(result)
									this.$message({
										message:result.msg,
										type:'info'
									});
								})
							}
							
							
							// this.userid=result.data[0].id
							// console.log(this.userid)
							// var parpams2={
							// 	userId:this.userid,
							// 	money:this.money
							// }
							// recharge(parpams2).then(res=>{
							// 	let result = res.data
							// 		this.$message({
							// 			message:result.msg,
							// 			type:'info',
							// 		})
							// })
						})
					})
					.catch(()=>{
						
					});
				}
			}
		},
		
	}
</script>

<style>
<yle>
